Make GtkTreeView tell the column about expand space instead of just assigning column...
authorTristan Van Berkom <tristan.van.berkom@gmail.com>
Mon, 29 Nov 2010 09:04:47 +0000 (18:04 +0900)
committerTristan Van Berkom <tristan.van.berkom@gmail.com>
Mon, 29 Nov 2010 09:04:47 +0000 (18:04 +0900)
Also modified the api to open up the way for treeview to tell the column
about how much of its size is really used to render the area.

gtk/gtktreeprivate.h
gtk/gtktreeview.c
gtk/gtktreeviewcolumn.c

index 43fb6381c6649a7e06bf5b4455144019f009bc6d..8e11e18aa16aab2b81c79133a3f137f190b965bb 100644 (file)
@@ -419,7 +419,8 @@ void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
 void _gtk_tree_view_column_set_tree_view    (GtkTreeViewColumn *column,
                                             GtkTreeView       *tree_view);
 void _gtk_tree_view_column_set_width        (GtkTreeViewColumn *column,
-                                             int                width);
+                                             int                width,
+                                            int                internal_width);
 void _gtk_tree_view_column_unset_model      (GtkTreeViewColumn *column,
                                             GtkTreeModel      *old_model);
 void _gtk_tree_view_column_unset_tree_view  (GtkTreeViewColumn *column);
index 5c4c073e7a88fecd9579a46d791a2f40b2f50a3b..84948aa3b3324c1098c5a42b33a441b18ae6bb2b 100644 (file)
@@ -2360,6 +2360,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
        list = (rtl ? list->prev : list->next)) 
     {
       gint real_requested_width = 0;
+      gint internal_column_width = 0;
       gint old_width, column_width;
 
       column = list->data;
@@ -2387,7 +2388,6 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
       real_requested_width = gtk_tree_view_get_real_requested_width_from_column (tree_view, column);
 
       allocation.x = width;
-      _gtk_tree_view_column_set_width (column, real_requested_width);
 
       if (gtk_tree_view_column_get_expand (column))
        {
@@ -2395,11 +2395,11 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
            {
              /* We add the remander to the last column as
               * */
-             column->width += extra;
+             real_requested_width += extra;
            }
          else
            {
-             column->width += extra_per_column;
+             real_requested_width += extra_per_column;
              extra -= extra_per_column;
              number_of_expand_columns --;
            }
@@ -2407,16 +2407,21 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
       else if (number_of_expand_columns == 0 &&
               list == last_column)
        {
-         column->width += extra;
+         real_requested_width += extra;
        }
 
       /* In addition to expand, the last column can get even more
        * extra space so all available space is filled up.
        */
       if (extra_for_last > 0 && list == last_column)
-       column->width += extra_for_last;
+       real_requested_width += extra_for_last;
 
-      g_object_notify (G_OBJECT (column), "width");
+      /* XXX This needs to account the real allocated space for
+       * the internal GtkCellArea
+       */
+      internal_column_width = real_requested_width /* - all the stuff treeview adds around the area */;
+
+      _gtk_tree_view_column_set_width (column, real_requested_width, internal_column_width);
 
       column_width = gtk_tree_view_column_get_width (column);
       allocation.width = column_width;
index ae375479d115fbc4ea5a11772613baa464a8c683..363082cfa4d486a08e35eb6b2efb1454abb87c3a 100644 (file)
@@ -1729,12 +1729,15 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
 
 void
 _gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
-                                 int                width)
+                                 int                width,
+                                int                internal_width)
 {
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
 
-  gtk_cell_area_context_allocate (tree_column->cell_area_context, width, -1);
+  gtk_cell_area_context_allocate (tree_column->cell_area_context, internal_width, -1);
   tree_column->width = width;
+
+  g_object_notify (G_OBJECT (tree_column), "width");
 }
 
 /**